set
A mutable set of elements of type T, where T is immutable. Subtype of collection<T>. Implemented as a hash-set, with iteration order determined by the order in which the elements were added.
Since
0.6.0
See also
Constructors
Functions
Add all elements from another collection to the end of this collection.
If this collection does not allow duplicates, then only those elements not already contained in this collection are added.
Returns a new set containing the elements of this set and the elements of a given collection.
a.add_all_copy(b) is equivalent to a + b, where a and b are sets.
Examples:
set([1]).add_all_copy(set([1]))returnsset([1])set([1, 2, 3]).add_all_copy(set([2, 3, 4]))returnsset([1, 2, 3, 4])
Add all elements from another collection to the end of this collection.
If this collection does not allow duplicates, then only those elements not already contained in this collection are added.
Check if this collection contains all elements of another collection.
Check if this collection contains all elements of another collection.
Generate a textual representation of this iterable.
An optional separator, prefix and postfix can be provided. One can also provide a limit: integer?. If there are more elements in the result than limit, the elements whose indices exceed limit are omitted, and the passed truncated: text is included instead.
Examples:
[1, 2, 3].join_to_text()returns'1, 2, 3'.[1, 2, 3].join_to_text('_')returns'1_2_3'.[1, 2, 3].join_to_text('*', '(', ')')returns'(1*2*3)'.list<T>().join_to_text('!', '(', ')')returns'()'(whereTis a valid type).range(10).join_to_text('', '', '', 5)returns'01234...'.range(10).join_to_text('', '', '', 5, 'more')returns'01234more'.
Where the function even is defined:
function even(x: integer): text {
return if (x % 2 == 0) 'EVEN' else 'ODD';
}Then:
range(10).join_to_text('->', '{', '}', 5, '...', even(*))returns{EVEN->ODD->EVEN->ODD->EVEN->...}.
Remove all elements in another collection from this collection.
Returns a new set containing the elements of this set, but without any elements that occur in the given collection.
a.remove_all_copy(b) is equivalent to a - b, where a and b are sets.
Examples:
set([1]).remove_all_copy(set([1]))returnsset([])set([1, 2, 3]).remove_all_copy(set([2, 3, 4]))returnsset([1])
Remove all elements in another collection from this collection.
Retain in this collection only those elements found in the given collection. In other words, remove from this collection all elements that are not found in the given collection.
Returns a new set whose elements are those found in both this set and the given collection, or in other words, the intersection of this set and the given collection.